#ifndef __VQUADTREE_H__
#define __VQUADTREE_H__
#include "VTerrainBlock.h"
#include "VSceneObject.h"

class VQuadTreeNode
{
public:
	enum{
		LEAF_SIZEX = VTERR_BLOCK_SIZEX,
		LEAF_SIZEY = VTERR_BLOCK_SIZEY,
	};
	VQuadTreeNode();
	~VQuadTreeNode();
	void Clear();
	inline VRect& GetBound() { return m_Bound;}
	void AddElement(VSceneObject* Element);
	void RemoveElement(VSceneObject* Element);
	void GetVisibleElements(const VCamera* Camera, vstl::vector<VSceneObject*>& VisibleArray, EVFrustumCull VisibleFlag = VFC_UNKNOWN);
private:
	void AddToNode(VSceneObject* Element, const VBound& Bound);
	typedef vstl::vector<VSceneObject*> ElementList;
	ElementList m_Elements;
	VRect	m_Bound;
	VQuadTreeNode* m_Childs;
	BOOL m_IsLeaf;
};

#endif 